package com.icss.day03;

public class Test17 {

    public static void main(String[] args) {
        E<Number> a1 = new F();
        a1.call();

        // 匿名内部类
        E<Number> a2 = new E<Number>() {
            @Override
            public void call() {
                System.out.println("匿名类.call()");
            }
        };

        a2.call();

        AList alist = new AList();
        alist.args = new int[]{1,3,5,7};
        Arithmatic arithmatic = new Arithmatic() {
            @Override
            public void xiaofei(int i) {
                System.out.println(i);
            }
        };
        alist.forEach(arithmatic);
        System.out.println("------参数是匿名--------");
        alist.forEach(new Arithmatic() {
            @Override
            public void xiaofei(int i) {
                System.out.println(i);
            }
        });
        System.out.println("-------Lambda-------");
        alist.forEach((int i) -> System.out.println(i));

        System.out.println("-------Lambda 变形-------");
        alist.forEach(Test17::sysout);

//        Arrays.asList().forEach(System.out::println);

    }

    public static void sysout(int item) {
        System.out.println(item);
    }
}
class AList {
    int[] args;
    public void forEach(Arithmatic r) {
        for (int item: args) {
            r.xiaofei(item);
        }
    }
}
@FunctionalInterface
interface Arithmatic{
    void xiaofei(int i);
}
class E<I extends Number> {
    public void call() {
        System.out.println("E.call()");
    }
}
class F extends E<Number> {
    @Override
    public void call() {
        System.out.println("F.call()");
    }
}
